package com.andy.wan.android.mvp.ui.adapter;

import com.andy.wan.android.R;
import com.andy.wan.android.mvp.bean.WxAuthor;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

/**
 * @Author: luofan
 * @CreateDate: 2020/4/2 16:55
 * @Description:
 */
public class WxArticleAdapter extends BaseQuickAdapter<WxAuthor, BaseViewHolder> {

    private int[] mBgColor = new int[]{R.color.red, R.color.colorPrimary, R.color.yellow, R.color.orange};

    public WxArticleAdapter() {
        super(R.layout.adapter_wx_article);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, WxAuthor item) {
        int color = ContextCompat.getColor(mContext, mBgColor[helper.getAdapterPosition() % 4]);
        helper.setBackgroundColor(R.id.root_layout, color);
        helper.setText(R.id.tv_name, item.getName());
    }
}
